
var page = Page({
	data: {
		loading: false,
		height: 2000,
	},
	init: function (render) {
		// let self = this;
		// this.getData(function (res) {
		// 	let data = self.formatData(res);
		// 	render(data);
		// })

		this.getData().then(this.formatData).then(render)
	},
	render: function (data) {
		var str = 'hello is ' + data.hello + '<br>';
		str += 'arr list is : ' + data.arr1 + ' , ' + data.arr2 + ' , ' + data.arr3 + ' .';
		str += 'good is ' + data.good;
		$('#container').html(str);
	},
	methods: {
		getData: function (cb) {
			let res = {
				success: true,
				data: {
					good: true,
					arr: [1,5,76],
					hello: '你好'
				}
			}
			this.setData({
				list: [1,2,4]
			})
			cb(res);
		},
		formatData: function (res, resolve) {
			let data = res.data;

			resolve({
				good: data.good,
				arr1: data.arr[0],
				arr2: data.arr[1],
				arr3: data.arr[2],
				hello: data.hello
			})
			// return {
			// 	good: data.good,
			// 	arr1: data.arr[0],
			// 	arr2: data.arr[1],
			// 	arr3: data.arr[2],
			// 	hello: data.hello
			// }
		},
		renderFun(data) {
			console.log(this.data)
			console.log(data)
		}
	},
	onclick: {
		'.J_toggle': function (ev, app) {
			console.log(this)
			console.log(app)
		},
		'.J_input': function (ev, app) {
			console.log(this)
			console.log(app.data)
		}
	},
	onchange: {
		'.J_input': function (ev, app) {
			console.log($(this).val())
		}
	},
	dropload(next) {
		console.log('完成')
		$('body').height(this.data.height += 500);

		this.formatData({
			data: {
				good: false,
				arr: [10000,50000,760000],
				hello: '我去哈哈哈'
			}
		}).then(this.render.bind(this))

		// let data = this.formatData({
		// 	data: {
		// 		good: false,
		// 		arr: [10000,50000,760000],
		// 		hello: '我去哈哈哈'
		// 	}
		// })
		// this.render(data);
		next(false);
	}
}, {
	isOpenPromise: true
})
